<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="vtc" uri="/ls-trade-tags"%>
<%@ include file="/common/taglibs.jsp"%>

<html>
<head>
	<title>设备<s:text name="common.btn.search"/></title>
	
	<script type="text/javascript">
	
	function clickBtn(action,id,e){
		
		switch(action){
		case "create":
			window.location="device!input.action";
			return;
			
		case "clear":
			$("#mainForm").attr("action","device!list.action?clear=true");
			break;
			
		case "search":
			$("#mainForm").attr("action","device!list.action");
			break;	
			
		case "sendMsg":
			parent.popup(e, 'command-publish-to-device.action?no-decorate&deviceId='+id, 'width:650;height:650;');
			return;	
			
		case "edit":
			$("#mainForm").attr("action","device!input.action?device.id="+id);
			break;	
		}
		
		$("#mainForm").submit();
	}
	
	</script>

</head>
<body>

<div class="content">  
  <div class="pageTitle">设备<s:text name="common.btn.search"/></div>
  
  <s:form id="mainForm" name="mainForm" action="device.action" method="post">
  	<s:hidden name="search"></s:hidden>
  	
  	  <div class="form1">
    	<table border="0" cellspacing="0" cellpadding="0">
	      <tr>
	        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
	        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
	        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
	        <td class="sep sep2" ><img src="../images/spacer.gif" /></td>
	      </tr>
	      <tr>
	        <td><label class="fLabel" >设备序列号</label>
	          <div class="fField">
	            <s:textfield name="device.serialNumber" cssStyle="width:150px" cssClass="inputText"/>
	          </div></td>
	        <td><label class="fLabel" >设备名称</label>
	          <div class="fField">
	            <s:textfield name="device.name" cssStyle="width:150px" cssClass="inputText"/>
	          </div></td>
	      </tr>
     
        </table>
        
	    <div class="btnSet btnSetTypeB">
		      <div class="left" >
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="searchBtn" name="search" value="Search" onclick="clickBtn('search');"/>
		            </div>
		          </div>
		        </div>
		        
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="clearBtn" name="clear" value="Clear" onclick="clickBtn('clear');"/>
		            </div>
		          </div>
		        </div>
		        
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="createBtn" name="create" value="Create" onclick="clickBtn('create')"/>
		            </div>
		          </div>
		        </div>
		        
	      </div>
      	</div>
    
      </div>
        
	<s:if test="%{page!=null&&page.result!=null&&page.result.size()!=0}">
		<div class="sListBorder">
		   <div class="sList">
		     <table width="100%" cellspacing="0" cellpadding="0" border="0" class="sTable">
		       <tbody>
		       <tr>
		         <td class="sTh t">Serial Number</td>
		         <td class="sTh t">Device Name</td>
		         <td class="sTh t">Status</td>
		         <td class="sTh t" style="width:150px" >&nbsp;</td>
		         <td class="sTh t" style="width:100px" >&nbsp;</td>
		       </tr>
		       
		       <s:iterator value="page.result" var="device" status="st">
		       
		      	  <s:set var="trClass" value="'sRow1'"></s:set>
		    	  <s:if test="#st.index%2==0">
		       	 		<s:set var="trClass" value="'sRow2'"></s:set>
			       	 <s:else>
			       	    <s:set var="trClass" value="'sRow1'"></s:set>
			       	 </s:else>
				  </s:if>
				  
			      <tr class="<s:property value='#trClass'/>">
			         <td class="sCell">
				         <a href="device!input.action?device.id=<s:property value='#device.id'/>">
				         	<s:property value="#device.serialNumber"/>
				         </a>
			         </td>
			         <td class="sCell"><s:property value="#device.name"/></td>
			         <td class="sCell"><s:property value="#device.status"/></td>
					 <td class="sCell buttonCell">
					 
					 	<div class="button sbtn">
	                            <div class="left">
	                              <div class="right">
	                                <input type="button" onclick="clickBtn('sendMsg','<s:property value='#device.id'/>',event)" value="Send Command" name="" id="" class="inputButton">
	                              </div>
	                            </div>
	                        </div>
	                     </td>	
	                     
					 <td class="sCell buttonCell">
					 	<div class="button sbtn">
	                            <div class="left">
	                              <div class="right">
	                                <input type="button" onclick="clickBtn('edit','<s:property value='#device.id'/>')" value="<s:text name='common.btn.edit'/>" name="" id="" class="inputButton">
	                              </div>
	                            </div>
	                        </div>
	                     </td>	
	                                           		         
		      	 </tr>		       
		       </s:iterator>
		     </tbody>
		     </table>
		   </div>
		   
		   <vtc:paging page="%{page}"></vtc:paging>
		 </div>
	</s:if> 
	
  </s:form> 
</div>

</body>
</html>